#include <bits/stdc++.h>

using namespace std;

const int MAXN = 410;
const int mod = 1e9+7;

typedef long long ll;

int n,c,a[MAXN],b[MAXN];
ll f[MAXN][MAXN],p[MAXN][MAXN],s[MAXN][MAXN];

int main (){
	scanf("%d %d",&n,&c);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i <= n;i++) scanf("%d",&b[i]);
	for(int i = 1;i <= 400;i++){
		p[0][i] = 1;
		for(int j = 1;j <= c;j++) p[j][i] = p[j-1][i] * i % mod;
	}
	for(int i = 0;i <= c;i++){
		s[i][0] = p[i][0];
		for(int j = 1;j <= 400;j++) s[i][j] = (s[i][j-1] + p[i][j]) % mod;
	}f[0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= c;j++)
			if(f[i-1][j])
				for(int x = 0;x + j <= c;x++){
					f[i][j+x] = (f[i][j+x] + f[i-1][j] * (s[x][b[i]] - s[x][a[i]-1]) % mod) % mod;
				}
	}
	printf("%lld\n",(f[n][c] % mod + mod) % mod); return 0;
}
